<%@ include file="/taglibs.jsp"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<script>

    //退出用户
	function closeWindow(){
		window.close();
	}

	//注销
	function logoff(){
		//window.parent.location.href = "${ctx}/user/login";
		var url = '${ctx}/user/logoff';
		$.post(url, function(result) {
			if(result.success) {
				window.parent.location.href = "${ctx}/user/login";
			} else {
				$.messager.show({
					title: '友情提示',
					msg: result.msg
				});
			}
		}, 'json');
	}

	//修改密码对话框显示
	function loadUP(){
		$('#dlg_UP').dialog('open').dialog('setTitle','修改密码');
		$('#fm_UP').form('clear');
	}
	
	//保存密码按钮操作
	function saveUserPassword(){
		var new_pwd = $('#new_pwd').val();
		var pwd_again = $('#pwd_again').val();
		
		if(new_pwd!=pwd_again){
			$.messager.alert('友情提示','更新密码应与确认密码一致');
			return;
		}
		
		var url = '${ctx}/user/updatePwd';
		$('#fm_UP').form('submit',{
			url: url,
			onSubmit: function(){
				return $(this).form('validate');
			},
			success: function(result){
				var result = eval('('+result+')');
				if (result.success){
					$('#dlg_UP').dialog('close');
					$.messager.show({
						title: '提示',
						msg: '修改成功'
					});
					logoff();
				} else {
					$.messager.show({
						title: 'Error',
						msg: result.msg
					});
				}
			}
		});
	}
</script>

<style>
.con{
    width: 100%;
    margin: 0px;
}
</style>

<div id="header">
	<div class="con">
		<ul class="admin_login" style="margin-right: 45px;">
			<li><a href="javascript:void(0);">${username}</a></li>
			<li><a href="javascript:logoff();oid(0);">登出</a></li>
			<li><a href="javascript:loadUP();void(0);">修改密码</a></li>
		</ul>
		<img src="${res_black}/img/logo/topLogo.png" style="margin-top: 2px;width:127px;height:55px;margin-left:50px;" />
		<div style="color:#8E8E8E;font-size:18px;margin-left: 181px;margin-top: -42px;position:absolute;">运营管理后台</div>
	</div>
</div>



<!-- 修改窗口 -->
<div id="dlg_UP" class="easyui-window" title="修改密码"  iconCls="icon-edit" style="width:350px;height:220px;padding:10px 20px" closed="true" modal="true"  minimizable="false" maximizable="false">
	<div class="easyui-layout" fit="true">
		<div region="center" border="false">
			<!-- <div class="ftitle">密码信息</div> -->
			<form id="fm_UP" method="post">
				<table class="input">
					<tr>
						<th style="width:25px;">当前密码&nbsp;:</th>
						<td><input id="pre_pwd" type="password" name="pre_pwd" class="easyui-validatebox text" required="true"/></td>
					</tr>
					<tr>
						<th>更新密码&nbsp;:</th>
						<td><input id="new_pwd" type="password" name="new_pwd" class="easyui-validatebox text" required="true"/></td>
					</tr>
					<tr>
						<th>确认密码&nbsp;:</th>
						<td><input id="pwd_again" type="password" name="pwd_again" class="easyui-validatebox text" required="true"/></td>
					</tr>
				</table>
			</form>
		</div>
		<div region="south" border="false" style="text-align:right;height:30px;line-height:30px;">
			<center>
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUserPassword()">保存</a>&nbsp;&nbsp;&nbsp;
			<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg_UP').window('close')">取消</a>
			</center>
		</div>
	</div>
</div>
